
package com.gameai.tickettoride.core;


import java.util.ArrayList;


/**Player specific information
 * 
 * @author nix
 *
 */


public class Player {
  public static final int init_train_count = 45;
  
  int playerID;
  int score = 0;
  int available_trains = init_train_count;
  boolean isAI = false;
  City[] longest_route_cities;
 

  ArrayList<Rail> rails_owned = new ArrayList<Rail>();
  ArrayList<City> cities_owned = new ArrayList<City>();
 
  Hand hand;
   
  public Player(boolean AI, int id) {
      hand = new Hand();
      isAI = AI;
      playerID = id;
      cities_owned.add(tickettoride.getGraph().Cities[0]);
  }
  
  
  
  /**Top Level player method. game progresses by calling this method in a round table fashion.
   * 
   */
  public void take_turn(){
      
	  updateState();
	  
      if (isAI) {
          //get AI input
      } else {
          //get user input
      }
      
  }
  
  public void updateState(){
	          
	  for (Rail rail: tickettoride.getGraph().Rails) {
		  if (this.equals(rail.player[0]) && !rails_owned.contains(rail)) {
			  rails_owned.add(rail);
		  }
	  }
          
          for(City ci : tickettoride.getGraph().Cities){
              if(this.equals(ci.player[0]) && !cities_owned.contains(ci)){
                  cities_owned.add(ci);
              }
          }
  }
  
  public boolean equals(Player b) {
	  return playerID == b.playerID;
  }
  
  public void addToHand(Card c) {
      hand.addCard(c);
  }
  
  public Hand getHand() {
      return hand;
  }
  
}
